<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Pro;
use App\Att;
class CheckController extends Controller
{
    public function prolist(){
        $pros = Pro::orderBy('pid','desc')->get();
        return view('prolist',['pros'=>$pros]);
    }

    public function check($pid){
        $pros = pro::find($pid);
        return view('shenhe',['pros'=>$pros]);
    }

    public function checkPost(Request $req,$pid){
        //dd($req);
        $pro = Pro::find($pid);
        $att = Att::where('pid',$pid)->first();

        //写入数据库 projects
        $pro->title = $req->title;
        $pro->hrange = $req->hrange;
        $pro->rate = $req->rate;
        $pro->status = $req->status;

        //写入附属表
        $att->title = $req->title;
        $att->realname = $req->realname;
        $att->gander = $req->gender;
        $att->udesc = $req->udesc;

        if($pro->save() && $att->save()){
            return redirect('prolist');
        } else {
            echo '审核失败';
        }
    }
}
